import audio from '@blueos.media.audio.audioPlayer'
import { getSound } from '../setting/sound'

let _isSound = true

// 初始化音频
export const initMusic = (src = "/assets/audio/get.mp3") => {
  audio.src = src
  // @ts-ignore
  _isSound = getSound()
}

// 播放游戏成功音效
export const playSoundEffectSucc = () => {
  if (_isSound) {
    audio.play()
    // console.log('audio.play')
  }
}

// 释放音频
export const releaseMusic = () => {
  try {
    // @ts-ignore
    audio.release()
  } catch (err) {
    console.log('releaseMusic err')
  }
}